After a lot of tries I finally managed to get docker on my computer. So I have an app1 directory with the following files:
Dockerfile:
FROM node:latest
EXPOSE 8080
WORKDIR /app
COPY package-lock.json .
COPY package.json .
RUN npm install
CMD ["npm", "start"]
package.json:
{
"name": "app1",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "node src/server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}
Then a src directory with server.js:
'use strict';
// load package
const express = require('express');
const PORT = 8080;
const HOST = '0.0.0.0';
const app = express();
app.get('/greeting', (req,res) => {
res.send('hello ');
});
app.use('/', express.static('pages'));
app.listen(PORT, HOST);
console.log('up and running');
From the app1 directory I run:
docker build -t raff/node . The image gets built with no issues. So I try to run docker with sudo docker run --rm -p 3000:8080 -v /Users/me/Desktop/app1/src:/app/src -it raff/node
So I get message that node is up and running and as soon as I open localhost:3000 I get the error message.
Could someone point it out what's wrong?
Edit: Included the absolute path that was omitted before.